$(".phone-btn").click(function() {
	$(".header-nav ul").slideToggle()
});
(function($) {
	$.getUrlParam = function(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
		var r = window.location.search.substr(1).match(reg);
		if(r != null) {
			return unescape(r[2])
		}
		return null
	}
})(jQuery);
var serviceIP = "http://www.xhwed.com/";
var vueheader = null;
var vueslider = null;
var vuefooder = null;
var vuecontent = null;
var indexData = sessionStorage.indexData;
if(indexData) {
	drawIndex(JSON.parse(indexData))
} else {
	indexAjax()
}

function indexAjax() {
	$.ajax({
		type: "get",
		url: serviceIP + "shemhe.php/Official/index",
		async: true,
		dataType: "json",
		success: function(datas) {
			indexData = sessionStorage.indexData = JSON.stringify(datas);
			drawIndex(datas)
		}
	})
}

function drawIndex(datas) {
	vueheader = new Vue({
		el: "#header-nav",
		data: {
			headNav: datas.result.navigation,
			subUrl: "about-brief.html",
			footNav: datas.result.navigation,
			navIndex: $.getUrlParam("index") ? $.getUrlParam("index") : 0,
			subIndex: $.getUrlParam("subindex") ? $.getUrlParam("subindex") : 0
		}
	});
	if($("#mod-con").length == 1) {
		vuecontent = new Vue({
			el: "#mod-con",
			data: {
				headNav: datas.result.navigation,
				subUrl: "about-brief.html",
				navIndex: $.getUrlParam("index") ? $.getUrlParam("index") : 0,
				subIndex: $.getUrlParam("subindex") ? $.getUrlParam("subindex") : 0,
				allcases: null,
				allNews: null,
			},
			methods: {
				ifNews: function() {
					return this.navIndex == 0 && this.subIndex == 2
				},
				ifCase: function() {
					return this.navIndex == 0 && this.subIndex == 0
				}
			}
		})
	}
	if($(".slider-imgs").length == 1) {
		vueslider = new Vue({
			el: ".slider-imgs",
			data: {
				sliderImgs: datas.result.carousel
			}
		})
	}
	vuefooder = new Vue({
		el: ".footer",
		data: {
			footNav: datas.result.navigation,
			subUrl: "about-brief.html",
			subNav: datas.result.navigation,
			navIndex: $.getUrlParam("index") ? $.getUrlParam("index") : 0,
			subIndex: $.getUrlParam("subindex") ? $.getUrlParam("subindex") : 0
		}
	})
}
var caseData = sessionStorage.caseData;

function casesAjax(sucMethod) {
	if(caseData) {
		sucMethod(JSON.parse(caseData))
	} else {
		$.ajax({
			type: "get",
			url: serviceIP + "shemhe.php/Official/cases",
			async: true,
			dataType: "json",
			success: sucMethod
		})
	}
}
var newsData = sessionStorage.newsData;

function newsAjax(sucMethod) {
	if(newsData) {
		sucMethod(JSON.parse(newsData))
	} else {
		$.ajax({
			type: "get",
			url: serviceIP + "shemhe.php/Official/news",
			async: true,
			dataType: "json",
			success: sucMethod
		})
	}
};